var express = require('express');
var router = express.Router();
const qiniu = require('qiniu')
const { success, error } = require('../../utils/message')

// 上传文件
router.get('/', function(req, res, next) {
    const accessKey = process.env.ACCESS_KEY
    const secretKey = process.env.SECRET_KEY
    const mac = new qiniu.auth.digest.Mac(accessKey, secretKey)

    const options = { scope: process.env.SCOPE }
    const putPolicy = new qiniu.rs.PutPolicy(options)
    const uploadToken = putPolicy.uploadToken(mac)

    success(res, '生成成功', { uploadToken })
});

module.exports = router;
